<template>
  <div id="hospitalList">
    <van-nav-bar
      title="我的顾问"
      left-arrow
      left-text="返回"
      @click-left="onClickLeft"
      fixed
      placeholder
    ></van-nav-bar>

    <div class="box"  v-for="(item,index) in list" :key="index" @click="toHospitalList(item.id)">
      <div class="vanCell">
        <div class="vanCell_left">
          <img v-if="item.txurl !== null && item.txurl !== ''" :src="item.txurl" />
          <img v-else src="@/assets/images/avatar.png" alt="">
         <div class="nameBox">
            <p>{{item.name}}</p>
           <div class="tabel">
                <van-tag plain type="primary" > 医院{{ item.yynum }}家 </van-tag>
                <van-tag plain type="warning" > 医生{{ item.ysnum }}人 </van-tag>
                <van-tag type="danger" > 患者{{ item.hznum }}人</van-tag>
           </div>
         </div>
        </div>
        <div class="vanCell_right">
          <van-icon name="arrow" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import apiConfig from "../../../config/api.config";
import { guwenlist } from "@/apis/home";
export default {
  data() {
    return {
      yyid:'',
      apiConfig,
      list: [],
    };
  },
  methods: {
    hospital() {
      guwenlist()
      .then(res => {
        this.list = res.data
      })
      .catch((err) => {
        if(err.msg){
          this.$toast(err.msg);
        }else{
          this.$toast("网络错误"); 
        }
      });
    },
    onClickLeft() {
      this.$router.go(-1); //返回上一层
    },
    toHospitalList(id){
      console.log(id) 
      sessionStorage.setItem('adviserId',id)    
      this.$router.push(`/myHospitalList`)
    }

  },
  mounted() {
    this.hospital() 
  },
  created() {
    this.yyid = this.$route.params.yyid;
  },

};
</script>

<style lang="less">
#hospitalList {
  padding-bottom: 40px;
  .van-nav-bar {
    .van-nav-bar__text,
    .van-icon {
      color: #404040;
    }
  }
  .van-cell__title {
    text-align: left;
  }
  .box {
    width: 100vw;
    padding: 0 5vw;
    background: #fff;
    .vanCell {
      margin: 0 auto;
      padding: 10px 0;
      border-bottom: 1px solid #ebedf0;
      display: flex;
      justify-content: space-between;
      align-items: center;
      .vanCell_left {
        display: flex;
        align-items: center;
        .nameBox{
            display: flex;
            flex-direction: column;
            margin-left: 15px;
            p{
                text-align: left;
            }
            div{
                margin-top: 5px;
            }
        }
        img {
          display: block;
          width: 40px;
          height: 40px;
          border-radius: 50%;
        }
      }
    }
  }
}
</style>
